﻿cmake_minimum_required (VERSION 3.14.0)

project("Camera" VERSION 0.0.1 LANGUAGES C CXX)
set(CMAKE_BUILD_TYPE Debug)

set(JSONCPP_DIR /usr/local/src/jsoncpp-00.11.0)
set(JSONCPP_INCLUDE_DIR ${JSONCPP_DIR}/include)
set(JSONCPP_LIB_DIR ${JSONCPP_DIR}/build/lib)

set(FFMPEG_DIR /usr/local/src/ffmpeg-5.1.3)
set(FFMPEG_INCLUDE_DIR ${FFMPEG_DIR}/include)
set(FFMPEG_LIB_DIR ${FFMPEG_DIR}/lib)


# 引入Json
include_directories(${JSONCPP_INCLUDE_DIR})
link_directories(${JSONCPP_LIB_DIR})

# 引入FFMPEG
include_directories(${FFMPEG_INCLUDE_DIR})
link_directories(${FFMPEG_LIB_DIR})


# 编译 相关
# 设置 bin为输出二进制生成目录
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
# 添加源码
set(PROJECT_SOURCES
        base.h
        main.cpp
        Transfer.cpp
        Camera.h
        Camera.cpp
)

add_executable (${PROJECT_NAME} 
                ${PROJECT_SOURCES})
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})

# 动态链
target_link_libraries(${PROJECT_NAME}
        avcodec
        avdevice
        avfilter
        avformat
        avutil
        postproc
        swresample
        swscale
)

target_link_libraries(${PROJECT_NAME} jsoncpp)

# 第二种
# pkg_check_modules(ffmpeg REQUIRED IMPORTED_TARGET libavdevice 
#                                                   libavcodec
#                                                   libavfilter
#                                                   libavformat
#                                                   libavutil
#                                                   libpostproc
#                                                   libswresample
#                                                   libswscale
#                                                   )

# target_link_libraries(${PROJECT_NAME} PRIVATE PkgConfig::ffmpeg)